<template>
  <div class="app-container">
    <header>
      <div>
        <el-form inline :model="params" class="demo-form-inline" size="small" label-width="140px">
          <el-form-item label="驾校ID" label-width="60px">
            <el-input v-model="params.JxID" placeholder="输入驾校ID" @keyup.enter.native="getOnlineUser" clearable/>
          </el-form-item>
          <el-form-item label="用户名">
            <el-input v-model="params.theuserno" placeholder="输入用户名" @keyup.enter.native="getOnlineUser" clearable/>
          </el-form-item>
          <el-form-item label="IP">
            <el-input v-model="params.ip" placeholder="请输入IP" @keyup.enter.native="getOnlineUser" clearable/>
          </el-form-item>
          <el-form-item label=" " label-width="60px">
            <el-button type="primary" icon="el-icon-search" @click="getOnlineUser">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
    </header>
    <main>
      <div style="height: 690px;">
        <el-table :data="tableData" stripe border style="width: 100%" height="100%">
          <el-table-column fixed prop="sid" label="SID" width="220" align="center" />
          <el-table-column prop="userno" label="用户名" width="150" align="center">
            <template slot-scope="scope">
              <span style="color: #4d4de2;cursor: pointer;"
                @click="go(scope.row, 'http://jx.qida999.com/DriverCommon/system/loger.aspx')">{{
                  scope.row.userno }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="姓名" width="120" align="center" />
          <el-table-column prop="JxID" label="驾校ID" width="100" align="center">
            <template slot-scope="scope">
              <span style="color: #4d4de2;cursor: pointer;"
                @click="go2(scope.row, 'http://jx.qida999.com/DriverCommon/system/DrJx.aspx')">{{
                  scope.row.JxID }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="jxName" label="驾校名称" width="150" align="center" />
          <el-table-column prop="ip" label="IP" width="150" align="center" />
          <el-table-column prop="prov" label="省份市区" width="150" align="center" />
          <el-table-column prop="t" label="在线时间" width="190" align="center" />
          <el-table-column prop="firstTime" label="登录时间" width="190" align="center" />
          <el-table-column prop="type" label="登录方式" width="150" align="center" />
          <el-table-column prop="uid" label="粉丝ID" width="150" align="center">
            <template slot-scope="scope">
              <span style="color: #4d4de2;cursor: pointer;"
                @click="go3(scope.row, 'http://jx.qida999.com/DriverCommon/wx/pc/WxUserInfoAdd.aspx')">{{
                  scope.row.uid }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="headImg" label="头像" width="150" align="center">
            <template slot-scope="scope">
              <img :src="scope.row.headimgurl" style="height: 30px;width: 30px;" alt="暂无头像">
            </template>
          </el-table-column>
          <el-table-column prop="nickname" label="昵称" width="150" align="center" />
          <el-table-column label="操作" width="120" fixed="right" align="center">
            <template slot-scope="scope">
              <el-button type="info" size="mini" plain @click="offHandler(scope.$index, scope.row)">强制下线</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </main>
    <!-- 分页 -->
    <div class="pagin">
      <el-pagination background :current-page="params.page" :page-sizes="[20, 50, 100, 150]"
        layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" :page-size="params.pageSize" />
    </div>
  </div>
</template>

<script>
import { adminAPI } from '@/api/adminstare'

/**
* @author        Yng
* @time          2023-10-28 10:31:36  星期六
* @description   在线用户
**/

export default {
  data() {
    return {
      tableData: [],
      params: {
        action: 'pcWebOnlineList',
        page: 1,
        pageSize: 20,
        ip: '',//ip地址
        JxID: '',//驾校ID
        theuserno:'',//用户名
      },
      total: 0
    }
  },
  mounted() {
    this.getOnlineUser()
  },
  methods: {
    // 表格数据
    async getOnlineUser() {
      console.log(this.params);

      let { code, data, total } = await adminAPI(this.params)
      if (!code) {
        this.tableData = data
        this.total = total
      }
    },
    //  跳旧版详情
    go(val, URL) {
      const redirectUrl = `${URL}?&userno=${this.$store.getters.userInfo.userno}`
      this.$oldLoginSystem(redirectUrl)
    },
    go2(val, URL) {
      const redirectUrl = `${URL}?JxID=${val.JxID}`
      this.$oldLoginSystem(redirectUrl)
    },
    go3(val, URL) {
      const redirectUrl = `${URL}?id=${val.uid}`
      this.$oldLoginSystem(redirectUrl)
    },
    offHandler(index, row) {
      console.log('index-row :>> ', index, row)
    },
    // 一页几条数据
    handleSizeChange(val) {
      this.params.pageSize = val
      this.getOnlineUser();
    },
    // 当前页
    handleCurrentChange(val) {
      this.params.page = val
      this.getOnlineUser();
    },
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  background-color: white;

  main {
    &>div {
      height: 670px;
    }
  }
}
</style>
